#include <vector>

using namespace std;

class NumArray {
private:
    int* sums;

public:
    NumArray(vector<int>& nums) {
        int n = nums.size();
        sums = new int[n];
        sums[0] = nums[0];
        for (int i = 1; i < n; i++) { sums[i] = sums[i - 1] + nums[i]; }
    }

    int sumRange(int left, int right) {
        if (left == 0) return sums[right];
        return sums[right] - sums[left - 1];
    }
};